<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" src="js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/jquery.maskedinput-1.2.2.min.js"></script>
	<script type="text/javascript" language="javascript">
		
	$(function($){
		//init
		//$('.datetime').each(function(){$(this).mask('9999-99-99');})
		//$('.seconds').each(function(){$(this).mask('99');})
		//$.post('action.php','action=GetUsers',function(data){$('#A_USERS').html(data);})
		//eof init
		
		$('#form_queue').submit(function(){
			var tosend = $(this).serialize();
			$.post('test_s.php', tosend, function(data) {
				$('#result').html(data);
				$('#to_firm').show();
			})
			return false;
		})
		
		$('#chk_minup').live('click',function(){
			$('#plain').toggle();
			$('#minup').toggle();
		})
		btn_setperiod('monthbegin','date');
	})
	
	btn_setperiod = function(from_,to_){
		$('[name="db[queue_from]"]').val(getDatetime(from_));
		$('[name="db[queue_to]"]').val(getDatetime(to_));
	}
	getDatetime = function(k_){//k_ = [''|'date'|'time'] 
		//получение даты (сегодняшний день) вида DATETIME MySQL 
		//без ключа yyyy-mm-dd hh:mm:ss
		//ключ date только yyyy-mm-dd
		//ключ time только hh:mm:s
		var add0 = function(val_){val_+='';val_.length==1?val_='0'+val_:val_;return val_;}
		var date = new Date();
		var day = add0(date.getDate());
		var month = add0((date.getMonth()+1));
		var year = add0(date.getFullYear());
		var hour = add0(date.getHours());
		var min  = add0(date.getMinutes());
		var sec  = add0(date.getSeconds());
		
		switch(k_){
			case 'date':
				return year+'-'+month+'-'+day;	
			case 'time':
				return hour+':'+min+':'+sec;
			case 'ms':
				return hour+':'+min+':'+sec + '.' + date.getMilliseconds();
			case 'daybegin':
				return year+'-'+month+'-'+day+' 00:00:00';
			case 'dayend':
				return year+'-'+month+'-'+day+' 23:59:59';
			case 'monthbegin':
				return year+'-'+month+'-01';
			default : return year+'-'+month+'-'+day+' '+hour+':'+min+':'+sec;
				
		}
	}
	</script>

</head>
<body >
	<a href="http://webserver/stat_in/index2"> Монитор </a> 
 		<a href="http://webserver/stat_in/php/groups/modul.php"> Группы </a> 
		<a href="http://webserver/stat_in/php/projects/modul.php"> Проекты </a> 
		<a href="http://webserver/stat_in/php/groups_settings/modul.php"> Настройки групп </a>
	<div id="div_queue">
		<form id="form_queue">
			от<input type="text" class="date" name="db[queue_from]"	value="2011-01-01" />
			до<input type="text" class="date" name="db[queue_to]"		value="2011-01-05" />
			<input type="button" value="сегодня" onclick="javascript:btn_setperiod('date','date');"/>
			<input type="button" value="данный месяц" onclick="javascript:btn_setperiod('monthbegin','date');"/><br/>
			норма обслуживания <input type="text" class="seconds" name="opt[quality_sec]" value="20" />
			<span id="to_firm" style="displya:none">заказчику <input type="checkbox" name="opt[minup]" id="chk_minup" /></span>
			<input type="submit" value="запрос" />
		</form>
	</div>
	<div id="result">
	</div>
</body>
</html>